package com.bd.module.login.ui;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

public class PwdChangePanel extends JPanel{
	private static final long serialVersionUID = 4976162953452472422L;
	/**旧密码*/
	private final JTextField oldPass;
	/**新密码*/
	private final JTextField newPass;
	/**密码确认**/
	private final JTextField agNewPass;
	/**button的高度*/
	private int btnHeight = 30;
	private int btnWidth =86;
	private int jLabelWidth = 103;
	private int jLabelHeight = 21;
	/**按钮字体*/
	private final Font BTN_FONT = new Font("楷体", Font.PLAIN, 20);
	/**JLabel标签的字体样式*/
	private final Font LID_FONT = new Font("楷体", Font.PLAIN, 20);
	/**panel title字体大小*/
	private final Font Pane_FONT = new Font("楷体", Font.PLAIN, 20);
	private static PwdChangePanel passPanel;
	static public PwdChangePanel getPassPanel(){
		if(passPanel==null){
			passPanel=new PwdChangePanel();
		}
		return passPanel;
	}
	public PwdChangePanel(){
		/**提示信息*/
		final JLabel showLabel = new JLabel("");
		showLabel.setBounds(625, 298, 177, 15);
		add(showLabel);
		showLabel.setFont(LID_FONT);
		showLabel.setForeground(Color.red);
		
		setBorder(new TitledBorder(null, "\u4FEE\u6539\u767B\u5F55\u5BC6\u7801", TitledBorder.CENTER, TitledBorder.TOP, Pane_FONT, null));
		this.setLayout(null);
		
		final JLabel label_1 = new JLabel("原密码:");
		label_1.setBounds(607, 334, jLabelWidth, jLabelHeight);
		this.add(label_1);
		label_1.setFont(LID_FONT);
		oldPass = new JPasswordField();
		/***
		 * 监听输入框是否输入enter,每次输入以enter键座位结束
		 * */
		oldPass.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent keyEvent) {
				if(keyEvent.getKeyCode() == KeyEvent.VK_ENTER){
					String oldPas = new String(((JPasswordField) oldPass).getPassword());
					if(!"".equals(oldPas)){
						/**
						 * 判断输入旧密码是否正确
						 * **/
						
					}else{
						
					}
				}
			}
		});
		oldPass.setBounds(719, 334, 98, 21);
		this.add(oldPass);
		oldPass.setColumns(10);
		
		final JLabel label_2 = new JLabel("新密码:");
		label_2.setBounds(607, 364, jLabelWidth, jLabelHeight);
		this.add(label_2);
		label_2.setFont(LID_FONT);
		newPass = new JPasswordField();
		newPass.setBounds(719, 364, 98, 21);
		this.add(newPass);
		newPass.setColumns(10);
		
		final JLabel label_3 = new JLabel("密码确认:");
		label_3.setBounds(607, 394, jLabelWidth, jLabelHeight);
		this.add(label_3);
		label_3.setFont(LID_FONT);
		agNewPass = new JPasswordField();
		agNewPass.setBounds(719, 394, 98, 21);
		this.add(agNewPass);
		agNewPass.setColumns(10);
		
		JButton cancleBtn = new JButton("取消");
		cancleBtn.setBounds(731, 425, btnWidth, btnHeight);
		this.add(cancleBtn);
		cancleBtn.setFont(BTN_FONT);
		JButton EnsureBtn = new JButton("确认");
		EnsureBtn.setBounds(607, 425, btnWidth, btnHeight);
		this.add(EnsureBtn);
		EnsureBtn.setFont(BTN_FONT);
	}
	public JTextField getOldPass() {
		return oldPass;
	}
}
